//
fnc_updateRank = {
	params["_player", "_varName", "_default"];
	private _varPlayer = _player getVariable [_varName, _default];
	if(_varPlayer > profileNamespace getVariable [_varName, _default])then{
		profileNamespace setVariable[_varName, _varPlayer];
		missionNamespace setVariable[_varName, _varPlayer, true];
		
		private _name = format["%1_name", _varName];
		profileNamespace setVariable[_name, name _player];
		missionNamespace setVariable[_name, name _player, true];
	};
};


missionNamespace setVariable["as_rank_kill", profileNamespace getVariable["as_rank_kill", 0], true];
missionNamespace setVariable["FAR_count_revive", profileNamespace getVariable["FAR_count_revive", 0], true];
missionNamespace setVariable["FAR_count_down", profileNamespace getVariable["FAR_count_down", 0], true];
missionNamespace setVariable["as_play_time", profileNamespace getVariable["as_play_time", 0], true];
missionNamespace setVariable["as_win", profileNamespace getVariable["as_win", 0], true];
missionNamespace setVariable["as_kill", profileNamespace getVariable["as_kill", 0], true];

missionNamespace setVariable["as_rank_kill_name", profileNamespace getVariable["as_rank_kill_name", ""], true];
missionNamespace setVariable["FAR_count_revive_name", profileNamespace getVariable["FAR_count_revive_name", ""], true];
missionNamespace setVariable["FAR_count_down_name", profileNamespace getVariable["FAR_count_down_name", ""], true];
missionNamespace setVariable["as_play_time_name", profileNamespace getVariable["as_play_time_name", ""], true];
missionNamespace setVariable["as_win_name", profileNamespace getVariable["as_win_name", ""], true];
missionNamespace setVariable["as_kill_name", profileNamespace getVariable["as_kill_name", ""], true];

while{true}do
{
	uiSleep 60;
	{
		if(_x getVariable ["as_init", false]) then{
			
			//保存金钱
			if(Param_Money_save >= 1)then{
				[_x, "as_money", 0] call fn_savePlayerVar;
			};
			
			//更新游戏时间
			_x setVariable ["as_play_time", (_x getVariable["as_play_time", 0]) + 0.0167, true];
			
			//保存游戏时间
			[_x, "as_play_time", 0] call fn_savePlayerVar;
			
			//更新击杀数
			_x setVariable ["as_rank_kill", (getPlayerScores _x) select 5];
			
			//胜利次数 胜利时服务器更新
			/*
			[_x, "as_win", 0] call fn_savePlayerVar;
			*/
			
			//击中上校次数
			[_x, "as_kill", 0] call fn_savePlayerVar;
			
			//更新排行榜
			[_x, "as_rank_kill", 0] call fnc_updateRank;
			[_x, "FAR_count_revive", 0] call fnc_updateRank;
			[_x, "FAR_count_down", 0] call fnc_updateRank;
			[_x, "as_play_time", 0] call fnc_updateRank;
			[_x, "as_win", 0] call fnc_updateRank;
			[_x, "as_kill", 0] call fnc_updateRank;
		};
	}forEach AllPlayers;
	//systemChat "玩家数据已保存";
};
